<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div id="app"></div>
<script src="../React-js/react.development.js"></script>
<!--引入reac-dom 用于支持react操作dom-->
<script src="../React-js/react-dom.development.js"></script>
<!--引入babel 用于讲jsx语法转js语法-->
<script src="../React-js/babel.min.js"></script>
<script type="text/babel">
    class ShenMing extends React.Component {
        jie_dian = React.createRef() //获取节点
        state = {
            opacity: 1
        }
        sta

        render() {
            return <div ref={this.jie_dian}>
                <div style={{opacity: this.state.opacity}}>
                    <h1>我是什么</h1>
                    <p>我是谁</p>
                </div>
                <button onClick={this.hidden}>不活了</button>
            </div>
        }

        hidden = () => {
            console.log(this.jie_dian)
            //卸载节点
            ReactDOM.unmountComponentAtNode(document.getElementById('app'))
        }

        /**
         * 组件挂载完毕回调
         */
        componentDidMount() {
            console.log(111, this.jie_dian)
            this.dongHua()
        }

        /**
         * 组件将要卸载的回调
         */
        componentWillUnmount() {
            console.log('简要卸载')
            clearInterval(this.dong_hua_din_shi) //卸载定时器
        }
        componentDidUpdate() {
            console.log('更新完毕')
        }


        /**
         * 透明度动画
         */
        dongHua() {
            this.dong_hua_din_shi = setInterval(() => {
                const {opacity} = this.state
                console.log(11)
                this.setState({
                    opacity: opacity <= 0 ? 1 : opacity - 0.1
                })
            }, 200)
        }
    }

    ReactDOM.render(<ShenMing/>, document.getElementById('app'))
</script>
</body>
</html>
原数字是1，需要2秒钟减到0，每次剪0.01,球多久减一次
1-(x*0.01*2) = 0
